非同期であるかどうか分からない場合は、そうであったかのように関数を記述する必要があります。
プロデューサ/コンシューマの問題です:パケットが解読されていますか?だからセマフォは消費するものがあるまで待つように解決することができます。あなたのコールバック関数は、パケット解剖が終了したことを知らせる必要があります。消費するものがあります。
そして私は何だろうさ(擬似コード):
void my_callback()
{
semaphore.post()
}
// ...
dissected_information* MyDissectPacket(packet)
{
epan_dissect_run(packet) // asynchronous or not call
semaphore.wait() // if it is, it will stop here and wait the post() of the
// callback
// if it is not, it will result exaclty like above, but the
// semaphore will always be already "posted"; so you will just have
// a useless semaphore.
}
私は私が正しくあなたの問題を理解願っています...
EDIT:あなたの場合 はを通して、あなたの結果を得ますコールバック:
void my_callback(result)
{
shared_var_result = result;
semaphore.post()
}
// ...
dissected_information* MyDissectPacket(packet)
{
epan_dissect_run(packet) // asynchronous or not call
semaphore.wait() // if it is, it will stop here and wait the post() of the
// callback
// if it is not, it will result exaclty like above, but the
// semaphore will always be already "posted"; so you will just have
// a useless semaphore.
return shared_var_result
}
私は他の合理的な解決策を見ることができません。
この特定の場合、作業は同期して行われます。私が探しているのは、解剖ルーチンと呼ばれる機能の中から解剖結果にアクセスする方法だと思います。これはグローバル変数を使って行うことができますが、確実に良い方法が必要ですか? –
誰が結果を返すのですか? –